// 这个文件就是用来创建仓库的

import { legacy_createStore } from "redux";

// 初始数据
const initState = {
  count: 10,
  age: 100,
  name: "zhangsan",
};

// 改变数据的方法
const reducer = (state = initState, action) => {
  switch (action.type) {
    case "add":
      return {
        ...state,
        count: state.count + 1,
      };
    case "change":
      return {
        ...state,
        name: action.name,
      };
    default:
      return state;
  }
};

// 创建仓库实例
const store = legacy_createStore(reducer);

export default store;
